//////////////////////////////////////////////////////////////////////////////////
//	Copyright 2011 by Yosef Grabivker, ryuho@homenetworksoft.com
//
//   Licensed under the Apache License, Version 2.0 (the "License");
//   you may not use this file except in compliance with the License.
//   You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
//   Unless required by applicable law or agreed to in writing, software
//   distributed under the License is distributed on an "AS IS" BASIS,
//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//   See the License for the specific language governing permissions and
//   limitations under the License.
//////////////////////////////////////////////////////////////////////////////////

#ifndef STATUSCTRL_H_
#define STATUSCTRL_H_

#include "def.h"

class CStatusCtrl: public wxPanel, public IGUIBind
{
public:
							CStatusCtrl(wxWindow* parent, wxWindowID id=wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize);
	virtual					~CStatusCtrl();
	
	//IGUIBind
	virtual void			SetMaxVal(unsigned int nVal)		{ m_nMaxVal = nVal; Refresh();	}
	virtual unsigned int	GetMaxVal()							{ return m_nMaxVal; 		}
	virtual void			SetVal(unsigned int nVal)			{ SetLevel( (100*nVal)/(m_nMaxVal?m_nMaxVal:1) );	}
	
	virtual void			SetLevel(unsigned char perc) 		{ m_btLevel = perc>100?100:perc; Refresh(); } 
	virtual void			SetWarningLevel(unsigned char perc) { m_btWarningLevel = perc; Refresh();		} 
	virtual void			SetAlarmLevel(unsigned char perc)	{ m_btErrorLevel = perc; Refresh();			}
	virtual void 			SetVal(const wxString& str)			{}
	
protected:
	void					OnSize(wxSizeEvent& event);
	void					OnPaint(wxPaintEvent& event);
	void					OnMenu(wxMouseEvent& event);
	
	DECLARE_EVENT_TABLE()

private:
	void					DrawEmptyRect(wxCoord x, wxCoord y, class wxBufferedPaintDC& dc );
	void					DrawFilledRect(wxCoord x, wxCoord y, class wxBufferedPaintDC& dc, class wxColor& color  );
	void					DrawText(const wxString& text, wxCoord x, wxCoord y,  class wxBufferedPaintDC& dc );

	
private:
	unsigned char 			m_btLevel;
	unsigned char 			m_btWarningLevel;
	unsigned char 			m_btErrorLevel;
	unsigned int			m_nMaxVal;
};

#endif /*STATUSCTRL_H_*/
